<?php

namespace App\Http\Controllers\Test;

use App\Http\Controllers\Controller;
use App\Models\System\User;
use Illuminate\Support\Facades\Auth;

class UserController extends Controller
{
    /**
     * 切换用户
     */
    public function switchUser($user_id)
    {
        $user = User::where('user_id', $user_id)->first();
        if ($user) {
            Auth::login($user);
            return redirect()->route('home');
        } else {
            abort(404, '未找到用户名为 '.$user_id.' 的用户。');
        }
    }
}
